import logging
from fastapi import APIRouter, Query
from fastapi.exceptions import HTTPException

from app.controllers.camera import camera_config_controller
from app.schemas.base import Success
from app.schemas.camera import CameraConfigCreate

logger = logging.getLogger(__name__)
router = APIRouter()

@router.get("/config", summary="获取相机配置")
async def get_camera_config(camera_type: str = Query(..., description="相机类型")):
    """获取相机配置"""
    camera_obj = await camera_config_controller.get_by_camera_type(camera_type)
    return Success(data=await camera_obj.to_dict())

@router.post("/config", summary="更新相机配置")
async def update_camera_config(camera_config: CameraConfigCreate):
    """更新相机配置"""
    await camera_config_controller.create_or_update(camera_config)
    return Success(msg="Updated Successfully") 